package com.xiaoyu.net.dns;

import androidx.annotation.NonNull;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.List;

import okhttp3.Dns;

public class DnsProxy implements Dns {

    private static Dns sDns;

    public static void setDns(Dns dns) {
        sDns = dns;
    }

    @Override
    @NonNull
    public List<InetAddress> lookup(@NonNull String hostname) throws UnknownHostException {
        if (sDns == null) {
            return Collections.emptyList();
        }
        return sDns.lookup(hostname);
    }
}
